<?php
// 拿到前端发的数据
$id = $_GET['id'];
$name = $_GET['name'];
$price = $_GET['price'];
$num = $_GET['num'];

// 连接数据库
$conn = mysqli_connect('localhost', 'root', 'root', 'newdata');

// 设置编码
mysqli_query($conn, "set charset 'utf8'");
mysqli_query($conn, "set character set 'utf8'");

$sql = "update info set name = '$name', price = $price, num = $num where id = $id";
// 执行SQL语句
$res = mysqli_query($conn,$sql);
// 更新返回bool值

if($res){
	echo json_encode(array(
		"code" => 200,
		"body" => array(
			"msg" => "修改数据成功"
		)
	));
}else{
	echo json_encode(array(
		"code" => 205,
		"body" => array(
			"msg" => "网络错误，修改失败"
		)
	));
}



?>